<div class="bg_main bg_main_page">
    <div id="bg_main"></div>
</div>
<script type="text/javascript">
            var id = "<?= $this->session->userdata("id_share") ?>";
			var flashvars = {id:id,linkPost:'<?=PATH_URL.'contest/get_contest'?>',linkPostImage:'<?=PATH_URL?>'};
			swfobject.embedSWF(root+'static/flash/main.swf?v='+ <?=rand(1,1000)?>, 'bg_main', '760', '900', '9.0.45', root+'/swfobject/expressinstall.swf', flashvars, {base:root + "static/flash/",bgcolor: '#CCCCCC', menu: 'false',allowFullScreen:'true'});
    
        
        function clear_session()
        {
            <?php $this->session->set_userdata("id_share","0"); ?>
        }
        function scroll_top(){
            FB.Canvas.scrollTo(0,0);
        }
</script>

<script>
        function share(thumb,id,title,name){
            var title_new = 'Cùng xem lời hứa giúp mẹ của ' + name + ' trong Tết này !';
            var summary = 'Tết này con hứa sẻ ' + title
            var img = "<?=PATH_URL.'static/images/tim/timthumb.php?src='?>"+thumb+"<?='&w=380&h=280;zc=0&q=100'?>"; 
            var a= "<?=$this->session->userdata('FB_REDIRECT_PAGE').'?app_data='?>";
            <?php 
            $a='{"id":"';
            $b='"}';
            $url_share_comment1 = rawurlencode($a);
            $url_share_comment2 = rawurlencode($b);
            ?>
            
            var var1 =  "<?=$url_share_comment1?>";
            var var2 =  "<?=$url_share_comment2?>";
            var url = a+var1+id+var2;
            
            link_share = 'https://www.facebook.com/sharer/sharer.php?s=100&p%5bmedium%5d=106&p%5btitle%5d='+encodeURIComponent(title_new)+'&p%5bsummary%5d='+encodeURIComponent(summary)+'&p%5burl%5d='+encodeURIComponent(url)+'&p%5bimages%5d%5b0%5d='+encodeURIComponent(img);
            window.open(link_share+"&display=popup",'_blank','width=650,height=450,status=no,toolbar=no,menubar=no,location=no');    
            
        
        }
        function invite2()
        {
            link = '<?=$this->session->userdata('FB_REDIRECT_PAGE')?>';
            img ='<?= PATH_URL.'static/images/logo.png'?>';
            title = 'Cùng tham gia gởi lời hứa giúp mẹ Tết nay với P&G Cảm ơn mẹ để đem đến cho mẹ một món quà bất ngờ ';
            var title_invite_contest=$('#title_invite_contest').val();
            var des_invite=$('#des_invite').val();
            FB.ui({
                method: 'apprequests',
                message: title_invite_contest
            }, function (response) {
                if (response && response.to) {
                    var id=String(response.to);
                    //var _link = root+_link1;
                    
                    $.each(id.split(','), function(key, value) { 
                        FB.api('/'+value+'/feed', 'post', {
                            //message: link,
                            picture: img,
                            caption: decodeURIComponent(title),
                            name: decodeURIComponent(title),
                            link:link,
                            description:des_invite
                        }, function(response) {
                            if (!response || response.error) {
                                console.log('Error occured');
                            } else {
                                console.log('Post ID: ' + response.id);
                            }
                        }); 
                    });
                }
            });
            return false;     
        }

</script>